<template>
  <div class="box">
    <h3>任务列表</h3>
    <div class="list">
            <div :class="{ unfinished: item.status==false }" class="task" v-for="(item,index) in $store.state.tasklist" :key="index">
                <div>
                    <span><input @click="hand(item)" type="checkbox" :checked="item.status"></span>
                    <span>{{item.id}}</span>
                    <span>{{item.name}}</span>
                </div>
                <span>删除</span>
            </div>
            
            <div v-show="$store.state.tasklist.length == 0" class="empty">任务列表为空,请添加一个任务!</div>
        </div>
  </div>
</template>

<script>
export default {
methods:{
    hand(item){
        this.$store.commit('change',item);
    }
}
}
</script>

<style lang="scss" scoped>
.box .list .task{
    display: flex;
    justify-content: space-between;
    color: white;
    padding-left: 2vw;
    margin: 2vw 0;
    background-color: lightseagreen;
}
.box .list .task.unfinished{
    background-color: red;
}
.box .list .task span{
    display: inline-block;
    margin-right: 2vw;
}
.empty{
    text-align: center;
}

</style>